import store from "@/store";
import Moment from "moment";
import { getTypeListByCompanyId } from "@/formRules/common/autoComplete";
import { phoneValid, required } from "../validators";
console.log("phoneValid()==========");
console.log(phoneValid());
export const isAuditingList = () => {
  return [
    { value: "0", label: "否" },
    { value: "1", label: "是" }
  ];
};
export const typeList = () => {
  return [
    { value: "0", label: "待填报" },
    { value: "2", label: "审核中" },
    { value: "3", label: "回退" },
    { value: "4", label: "复审中" },
    { value: "1", label: "已完成" },
    { value: "5", label: "待确认" }
  ];
};
export const isHasPro = () => {
  return [
    { value: "0", label: "通过" },
    { value: "1", label: "不通过" }
  ];
};
export const searchRule = (isAdmin, companyId) => {
  return [
    {
      type: "select",
      hidden: isAdmin ? false : true,
      tableVisible: isAdmin ? true : false,
      title: "单位名称",
      field: "companyId",
      options: store.state.companyList,
      col: {
        span: 4
      },
      value: store.state.companyId
        ? Number(store.state.companyId)
        : companyId
        ? Number(companyId)
        : store.state.companyList.length
        ? store.state.companyList[0].value
        : null
    }
  ];
};

export const editRule = () => {
  return [
    {
      type: "input",
      field: "id",
      title: "id",
      hidden: true,
      value: "",
      col: {
        span: 24
      },
      props: {}
    },
    {
      type: "input",
      field: "year",
      title: "年份",
      tableVisible: true,
      value: "",
      col: {
        span: 24
      },
      props: {}
    },
    {
      type: "input",
      field: "didian",
      title: "服务地点",
      tableVisible: true,
      value: "",
      col: {
        span: 24
      },
      props: {}
    },
    {
      type: "input",
      field: "renshu",
      title: "服务人数（在编）",
      tableVisible: true,
      value: "",
      col: {
        span: 24
      },
      props: {}
    },
    {
      type: "input",
      field: "sbsl",
      title: "其中过免费维护期设备数量",
      tableVisible: true,
      value: "",
      col: {
        span: 24
      },
      props: {}
    },
    {
      type: "input",
      field: "zmwhgd",
      title: "桌面维护工单量（件）",
      tableVisible: true,
      value: "",
      col: {
        span: 24
      },
      props: {}
    },
    {
      type: "input",
      field: "zcry",
      title: "驻场人员数量",
      tableVisible: true,
      value: "",
      col: {
        span: 24
      },
      props: {}
    },
    {
      type: "input",
      field: "zcjb",
      title: "驻场人员级别",
      tableVisible: true,
      value: "",
      col: {
        span: 24
      },
      props: {}
    },
    {
      type: "input",
      field: "gzsc",
      title: "驻场工作时长",
      tableVisible: true,
      value: "",
      col: {
        span: 24
      },
      props: {}
    },
    {
      type: "input",
      field: "gznr",
      title: "工作内容",
      tableVisible: true,
      props: {
        type: "textarea"
      },
      value: "",
      col: {
        span: 24
      },
      props: {}
    },
    {
      type: "input",
      field: "shje",
      title: "审核金额",
      tableVisible: true,
      value: "",
      col: {
        span: 24
      },
      props: {}
    }
  ];
};

export const tableHeadList = () => {
  return [
    {
      title: "桌面及办公设备上两个运维周期运维情况表",
      rule: [
        {
          type: "input",
          field: "id",
          title: "id",
          hidden: true,
          value: ""
        },
        {
          type: "input",
          field: "year",
          title: "年份",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "didian",
          title: "服务地点",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "renshu",
          title: "服务人数（在编）",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "sbsl",
          title: "其中过免费维护期设备数量",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zmwhgd",
          title: "桌面维护工单量（件）",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zcry",
          title: "驻场人员数量",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zcjb",
          title: "驻场人员级别",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "gzsc",
          title: "驻场工作时长",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "gznr",
          title: "工作内容",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "shje",
          title: "审核金额",
          tableVisible: true,
          value: ""
        }
      ],
      list: []
    },
    {
      title: "政务信息化基础设施上两个运维周期运维情况表",
      rule: [
        {
          type: "input",
          field: "id",
          title: "id",
          hidden: true,
          value: ""
        },
        {
          type: "input",
          field: "year",
          title: "年份",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "didian",
          title: "资产名称",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "renshu",
          title: "其中过报废期设备数量",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "sbsl",
          title: "资产原小值（万元）",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zmwhgd",
          title: "故障工单量",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zcry",
          title: "驻场人员数量",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zcjb",
          title: "驻场人员级别",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "gzsc",
          title: "驻场工作时长",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "gznr",
          title: "工作内容",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "shje",
          title: "运维费用",
          tableVisible: true,
          value: ""
        }
      ],
      list: []
    },
    {
      title: "桌面及办公设备运维驻场服务需求表",
      rule: [
        {
          type: "input",
          field: "id",
          title: "id",
          hidden: true,
          value: ""
        },
        {
          type: "input",
          field: "didian",
          title: "服务地点",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "renshu",
          title: "服务对象人数（在编）",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "gznr",
          title: "工作内容",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zcry",
          title: "驻场人员数量",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "gzsc",
          title: "工作时长",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zmwhgd",
          title: "运维工作量（人月）",
          tableVisible: true,
          value: ""
        },

        {
          type: "input",
          field: "zcjb",
          title: "驻场人员级别",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "sbsl",
          title: "驻场原因",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "shje",
          title: "差异说明",
          tableVisible: true,
          value: ""
        }
      ],
      list: []
    },
    {
      title: "政务信息化基础设施运维驻场服务需求表",
      rule: [
        {
          type: "input",
          field: "id",
          title: "id",
          hidden: true,
          value: ""
        },
        {
          type: "input",
          field: "xh",
          title: "序号",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "gznr",
          title: "工作内容",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zcry",
          title: "驻场人员数量",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zcjb",
          title: "驻场人员级别",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "gzsc",
          title: "驻场工作时长",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zmwhgd",
          title: "运维工作量（人月）",
          tableVisible: true,
          value: ""
        }
      ],
      list: []
    },
    {
      title: "重要保障期运维服务需求表",
      rule: [
        {
          type: "input",
          field: "id",
          title: "id",
          hidden: true,
          value: ""
        },
        {
          type: "input",
          field: "xh",
          title: "序号",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "type",
          title: "重要保障期类型",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "renshu",
          title: "重要保障期次数",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "sbsl",
          title: "保障名称",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zmwhgd",
          title: "重要保障期周期",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "gznr",
          title: "服务要求",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zcry",
          title: "运维工作量（人日）",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zcjb",
          title: "驻场人员级别",
          tableVisible: true,
          value: ""
        }
      ],
      list: []
    },
    {
      title: "重大会议运维服务需求表",
      rule: [
        {
          type: "input",
          field: "id",
          title: "id",
          hidden: true,
          value: ""
        },
        {
          type: "input",
          field: "xh",
          title: "序号",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "type",
          title: "会议类型",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "renshu",
          title: "会议次数",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "sbsl",
          title: "会议名称",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zmwhgd",
          title: "会议时间/频率",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "gznr",
          title: "服务要求",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zcry",
          title: "运维工作量（人日）",
          tableVisible: true,
          value: ""
        },
        {
          type: "input",
          field: "zcjb",
          title: "驻场人员级别",
          tableVisible: true,
          value: ""
        }
      ],
      list: []
    }
  ];
};

export const controlRule = () => {
  return [
    {
      type: "input",
      field: "description",
      title: "描述",
      props: {
        type: "textarea"
      },
      value: null,
      tableVisible: true
    }
  ];
};

export const problemRule = () => {
  return [
    {
      type: "select",
      field: "existProblems",
      title: "审核结果",
      tableVisible: true,
      options: isHasPro(),
      filter: v => {
        return isHasPro().find(i => i.value === v)?.label || "--";
      },
      props: {
        disabled: false,
        readonly: false
      },
      value: "0"
      //   control: [
      //     {
      //       handle(val) {
      //         return Number(val) === 1;
      //       },
      //       rule: [...problemTemplate()]
      //     }
      //   ]
    }
  ];
};

export const problemTemplate = () => {
  return [
    {
      type: "input",
      field: "description",
      title: "意见内容描述",
      props: {
        type: "textarea",
        placeholder: "请输入意见内容描述!"
      },

      value: null,
      tableVisible: true
    }
    // {
    //   type: "FormListImageFile",
    //   field: "photo",
    //   title: "照片",
    //   props: {
    //     readonly: true
    //   },
    //   value: [],
    //   tableVisible: true
    // }
  ];
};

export const personRule = () => {
  return [
    {
      type: "input",
      field: "tianbaoName",
      title: "联系人",
      tableVisible: true,
      value: "",
      col: {
        span: 12
      }
    },
    {
      type: "input",
      field: "tianbaoPhone",
      title: "联系方式",
      tableVisible: true,
      value: "",
      validate: [phoneValid(), required()],
      col: {
        span: 12
      }
    }
  ];
};

export const sureRule = () => {
  return [
    {
      type: "FormFileList",
      field: "fujianList",
      title: "附件",
      props: {
        readonly: true
      },
      value: [],
      tableVisible: true
    }
  ];
};

export const colorList = () => {
  return [
    {
      name: "填报完成",
      color: "#00b82b"
    },
    {
      name: "未提交填报",
      color: "#e4c900"
    },
    { name: "回退", color: "#f60101" },
    { name: "未提交", color: "#ccc" }
  ];
};
